
********************************
* Standard Stata Configuration *
********************************

clear all
capture log close
set logtype text
cap cd "G:\My Drive\1_Research"
cap cd "C:\Users\jordan.becker\My Drive\1_Research"
log using "wales_pledge\log\wales_pledge.log", replace
set more off


********************
* Prepare the Data *
********************
*Start with Master Data* 
use "dta\2021_master", clear



*Subset to Wales Project Data For Tim*
drop if countryname=="Iceland"
#delimit;
keep qualscore qualcategory year ccode countryname right milburden equipment_gdp personnel_gdp operating_gdp infrastructure_gdp ny_gdp_mktp_kd_zg log_investmentgdp ny_gdp_mktp_kd rank_on_gdp
ln_pop ln_gdp russia_spatial ms_mil_xprt_kd ms_mil_mprt_kd nato_dummy sl_uem_totl_zs fri pv_est isoalpha;
#delimit cr;
saveold "wales_pledge\dta\wales_pledge_subset.dta", replace
export excel using "wales_pledge\raw\wales_pledge_subset.xls", firstrow(varlabels) replace

*Wales Pledge Enthusiasm, captured in QCA fuzzy set, is a function of russia_spatial and abatement cost*
use "dta\2021_master", clear 
replace fri=0 if fri==.
rename qualscore qualscore_walespledge
lab var qualscore "Score for Wales Pledge Enthusiasm (0-1)"
rename qualcategory qualcategory_walespledge
lab var qualcategory "Category for Wales Pledge Enthusiasm (Instigator - Strong Dragger)"
bysort ccode (qualscore_walespledge): replace qualscore_walespledge = qualscore_walespledge[1]

*Merge Russia Sentiment Data for R1*

merge 1:1 ccode year using "wales_pledge\dta\russia_sentiment"
drop _merge


*Generate Compliance Metric equipment_gdp growth 2014-2022*
tsset ccode year
gen g_equipment_gdp=d.equipment_gdp/l.equipment_gdp
gen equipment_gdp_2014=equipment_gdp if year==2014
bysort ccode(equipment_gdp_2014): replace equipment_gdp_2014 = equipment_gdp_2014[1]
gen milburden_2014=milburden if year==2014
bysort ccode(milburden_2014): replace milburden_2014 = milburden_2014[1]
generate g_equipment_gdp_2014_2022=(equipment_gdp-equipment_gdp_2014)/equipment_gdp_2014 
generate g_milburden_2014_2022=(milburden-milburden_2014/milburden_2014)

*Generate 2014-2017 Compliance metric*
gen equipment_gdp_2017=equipment_gdp if year==2017
bysort ccode(equipment_gdp_2017): replace equipment_gdp_2017 = equipment_gdp_2017[1]
gen milburden_2017=milburden if year==2017
bysort ccode(milburden_2017): replace milburden_2017 = milburden_2017[1]

gen g_equipment_gdp_2014_2017=(equipment_gdp_2017-equipment_gdp_2014)/equipment_gdp_2014
gen g_milburden_2014_2017=(milburden_2017-milburden_2014)/milburden_2014

gen annual_g_equipment_gdp_2014_2017=(equipment_gdp_2017-equipment_gdp_2014)/equipment_gdp_2014/3
gen annual_g_milburden_2014_2017=(milburden_2017-milburden_2014)/milburden_2014/3

sum g_equipment_gdp_2014_2017 if nato_dummy==1
sum g_milburden_2014_2017 if nato_dummy==1


*Generate 2017-2021 Compliance metric*
gen equipment_gdp_2021=equipment_gdp if year==2021
bysort ccode(equipment_gdp_2021): replace equipment_gdp_2021 = equipment_gdp_2021[1]
gen milburden_2021=milburden if year==2021
bysort ccode(milburden_2021): replace milburden_2021 = milburden_2021[1]

gen g_equipment_gdp_2017_2021=(equipment_gdp_2021-equipment_gdp_2017)/equipment_gdp_2017
gen g_milburden_2017_2021=(milburden_2021-milburden_2017)/milburden_2017

gen annual_g_equipment_gdp_2017_2021=(equipment_gdp_2021-equipment_gdp_2017)/equipment_gdp_2017/4
gen annual_g_milburden_2017_2021=(milburden_2021-milburden_2017)/milburden_2017/4

sum g_equipment_gdp_2017_2021 if nato_dummy==1 & year==2021
sum g_milburden_2017_2021 if nato_dummy==1 & year==2021

sum annual_g_equipment_gdp_2017_2021 if nato_dummy==1 & year==2021
sum annual_g_milburden_2017_2021 if nato_dummy==1 & year==2021


*Generate 2021-2023 Compliance metric*
gen equipment_gdp_2023=equipment_gdp if year==2023
bysort ccode(equipment_gdp_2023): replace equipment_gdp_2023 = equipment_gdp_2023[1]
gen milburden_2023=milburden if year==2023
bysort ccode(milburden_2023): replace milburden_2023 = milburden_2023[1]

gen g_equipment_gdp_2021_2023=(equipment_gdp_2023-equipment_gdp_2021)/equipment_gdp_2021
gen g_milburden_2021_2023=(milburden_2023-milburden_2021)/milburden_2021

gen annual_g_equipment_gdp_2021_2023=(equipment_gdp_2023-equipment_gdp_2021)/equipment_gdp_2021/2
gen annual_g_milburden_2021_2023=(milburden_2023-milburden_2021)/milburden_2021/2

sum g_equipment_gdp_2021_2023 if nato_dummy==1 & year==2023
sum g_milburden_2021_2023 if nato_dummy==1 & year==2023

sum annual_g_equipment_gdp_2014_2017 if nato_dummy==1 & year==2017 & ccode!=2
sum annual_g_milburden_2014_2017 if nato_dummy==1 & year==2017 & ccode!=2

sum annual_g_equipment_gdp_2017_2021 if nato_dummy==1 & year==2021 & ccode!=2
sum annual_g_milburden_2017_2021 if nato_dummy==1 & year==2021 & ccode!=2

sum annual_g_equipment_gdp_2021_2023 if nato_dummy==1 & year==2023 & ccode!=2
sum annual_g_milburden_2021_2023 if nato_dummy==1 & year==2023 & ccode!=2



*Generate Abatement Cost = 2% - milburden*
gen abatement=2-milburden

*Generate Equpiment Abatement Cost = .4% - equipment_gdp (e.g. 2%*20% - curent equipment_gdp)*
gen abatement_equipment=.4-equipment_gdp 

*generate arms export/import balance*
gen arms_balance =ms_mil_xprt_kd - ms_mil_mprt_kd

*Update qualcategory_walespledge based on Paul & Pete*
replace qualcategory_walespledge = "Strong Dragger" if (countryname=="Germany"|countryname=="Luxembourg") & qualcategory_walespledge!="."

sencode qualcategory_walespledge, gsort(-qualscore_walespledge) replace 

*Change Germany and Luxemboug to Strong Draggers based on Paul & Pete"
replace qualscore_walespledge=.1 if countryname=="Germany"|countryname=="Luxembourg" & qualscore_walespledge!=.

*generate logs*
gen ln_milburden=ln(milburden)
gen ln_equipment_gdp=ln(equipment_gdp)


*Generate Opportunity Cost of Milex*
*xtreg ggdp_wdi linv_wdi lmilburden lngdpop_wdi lgdp1_wdi year*
sort ccode year
xtreg d.ny_gdp_mktp_kd_zg log_investmentgdp ln_milburden d.ln_pop l.ln_gdp year
xtreg d.ny_gdp_mktp_kd_zg log_investmentgdp ln_equipment_gdp d.ln_pop l.ln_gdp year



gen ggdp=d.ny_gdp_mktp_kd_zg
gen gln_pop=d.ln_pop
gen lag_ln_gdp=l.ln_gdp

*preserve
*keep if year<=2014 & nato_dummy==1
*rangestat (reg) ggdp log_investmentgdp ln_equipment_gdp gln_pop lag_ln_gdp, by(ccode) interval(ggdp . .) 


*Generate opportunity cost informed abatement*
*gen abatement_opportunity=2-equipment_gdp*-b_ln_equipment_gdp

*egen rank_abatement=rank(abatement) if abatement!=., by(year)
*egen rank_abatement_opportunity=rank(abatement_opportunity) if abatement_opportunity!=., by(year)


*Generate Sprinz & Vaahtoranta Categories: Abatement*
egen median_abatement = median(abatement) if year==2014 & nato_dummy==1
gen high_abatement=. if year==2014 & nato_dummy==1
replace high_abatement=1 if abatement>median_abatement & year==2014 & nato_dummy==1
replace high_abatement=0 if abatement<=median_abatement & year==2014 & nato_dummy==1
list countryname high_abatement if year==2014 & year==2014 & nato_dummy==1

*Generate Sprinz & Vaahtoranta Categories: Equipment-Adjusted Abatement*
egen median_abatement_equipment = median(abatement_equipment) if nato_dummy==1 & year==2014
gen high_abatement_equipment=. if nato_dummy==1 & year==2014
replace high_abatement_equipment=1 if abatement_equipment>median_abatement_equipment & year==2014 & nato_dummy==1
replace high_abatement_equipment=0 if abatement_equipment<=median_abatement_equipment & year==2014 & nato_dummy==1
list countryname high_abatement_equipment if year==2014

*Generate Sprinz & Vaahtoranta Categories: Threat Vulnerability*
egen median_russia_spatial = median(russia_spatial) if nato_dummy==1 & year==2014
gen high_russia_spatial=.
replace high_russia_spatial=1 if russia_spatial>median_russia_spatial&year==2014
replace high_russia_spatial=0 if russia_spatial<=median_russia_spatial&year==2014
list countryname high_russia_spatial if year==2014

*Generate Categories*
gen abatement_category=""
replace abatement_category="High" if high_abatement==1 & year==2014 & nato_dummy==1
replace abatement_category="Low" if high_abatement==0 & year==2014 & nato_dummy==1
encode abatement_category, gen (abatement_category_enc)

gen abatement_equipment_category=""
replace abatement_equipment_category="High" if high_abatement_equipment==1 & year==2014 & nato_dummy==1
replace abatement_equipment_category="Low" if high_abatement_equipment==0 & year==2014 & nato_dummy==1
encode abatement_equipment_category, gen (abatement_equipment_category_enc)

gen russia_spatial_category=""
replace russia_spatial_category="High" if high_russia_spatial==1 & year==2014 & nato_dummy==1
replace russia_spatial_category="Low" if high_russia_spatial==0 & year==2014 & nato_dummy==1
encode russia_spatial_category, gen (russia_spatial_category_enc)

gen threat_vuln_pred=""
replace threat_vuln_pred="Bystander" if abatement_equipment_category=="Low" & russia_spatial_category=="Low"
replace threat_vuln_pred="Pusher" if abatement_equipment_category=="Low" & russia_spatial_category=="High"
replace threat_vuln_pred="Dragger" if abatement_equipment_category=="High" & russia_spatial_category=="Low"
replace threat_vuln_pred="Intermediate" if abatement_equipment_category=="High" & russia_spatial_category=="High"
encode threat_vuln_pred, gen(threat_vuln_pred_enc)

********************
* Analyze the Data *
********************
sort ccode year

*Replicate Sprinz & Vaahtoranta 2 by 2*
list countryname if threat_vuln_pred=="Bystander"
list countryname if threat_vuln_pred=="Pusher"
list countryname if threat_vuln_pred=="Dragger"
list countryname if threat_vuln_pred=="Intermediate"




********************************************************************
* MAIN TABLE (Table 4): Equipment Abatement Cost - All Interactions*
********************************************************************

*Mean Comparison - try to find a way to order this by category instead of alphabetical*
#delimit;
tabstat abatement_equipment russia_spatial, by(qualcategory_walespledge);

*Model 1 (Baseline): Pledge = f(abatement_equipment cost, russia_spatial)*
#delimit;
reg qualscore_walespledge c.l.abatement_equipment##c.l.russia_spatial if year==2014 & nato_year_dummy==1;
outreg2 using "wales_pledge/output/walespledge_equipment.xls", ctitle (Baseline - Abatement&Threat) label addtext() bdec(2) cdec(2) pdec(2) tdec(2) replace;
interflex qualscore_walespledge abatement_equipment capdist_russia if year==2014 & nato_year_dummy==1, type(linear) ylabel ("Wales Pledge Agreement") dlabel ("Abatement Cost") xlabel ("Russia Threat") sav(wales_pledge/output/abatement_equipment_model1);
graph save wales_pledge/output/abatement_agreement_model1interactions, replace;


*Model 2 (Size: GDP)*
#delimit;
reg qualscore_walespledge c.l.abatement_equipment##c.l.russia_spatial c.l.rank_on_gdp##c.l.russia_spatial if year==2014 & nato_year_dummy==1;
outreg2 using "wales_pledge/output/walespledge_equipment.xls", ctitle (Public Choice) label addtext() bdec(2) cdec(2) pdec(2) tdec(2) append;
interflex qualscore_walespledge abatement_equipment capdist_russia rank_on_gdp if year==2014 & nato_year_dummy==1, type(linear) ylabel ("Wales Pledge Agreement") dlabel ("Abatement Cost") xlabel ("Capital Distance from Moscow") sav(wales_pledge/output/abatement_equipment_model2);
graph save wales_pledge/output/abatement_agreement_model2interactions, replace;

*Model 3 (Domestic Political Economy: right executive and uem)*
#delimit;
reg qualscore_walespledge c.l.abatement_equipment##c.l.russia_spatial c.l.rank_on_gdp##c.l.russia_spatial c.l.right##c.l.russia_spatial c.l.sl_uem_totl_zs##c.l.russia_spatial if year==2014 & nato_year_dummy==1;
outreg2 using "wales_pledge/output/walespledge_equipment.xls", ctitle (Domestic PE) label addtext() bdec(2) cdec(2) pdec(2) tdec(2) append;
interflex qualscore_walespledge abatement_equipment capdist_russia rank_on_gdp right sl_uem_totl_zs if year==2014 & nato_year_dummy==1, type(linear) ylabel ("Wales Pledge Agreement") dlabel ("Abatement Cost") xlabel ("Capital Distance from Moscow") sav(wales_pledge/output/abatement_equipment_model3);
graph save wales_pledge/output/abatement_agreement_model3interactions, replace;


*Model 4 (EU Political Economy: FRI)
#delimit;
reg qualscore_walespledge c.l.abatement_equipment##c.l.russia_spatial c.l.rank_on_gdp##c.l.russia_spatial c.l.right##c.l.russia_spatial c.l.sl_uem_totl_zs##c.l.russia_spatial c.l.fri##c.l.russia_spatial if year==2014 & nato_year_dummy==1;
outreg2 using "wales_pledge/output/walespledge_equipment.xls", ctitle (EU PE) label addtext() bdec(2) cdec(2) pdec(2) tdec(2) append;
interflex qualscore_walespledge abatement_equipment capdist_russia rank_on_gdp right sl_uem_totl_zs fri if year==2014 & nato_year_dummy==1, type(linear) ylabel ("Pledge Agreement") dlabel ("Abatement") xlabel ("Capital Distance from Moscow");
graph save wales_pledge/output/abatement_agreement_model4interactions, replace;
graph export wales_pledge/figures/figure4_abatement_agreement_model4interactions.tif, replace;

grc1leg wales_pledge/output/abatement_agreement_model1interactions.gph wales_pledge/output/abatement_agreement_model2interactions.gph wales_pledge/output/abatement_agreement_model3interactions.gph
wales_pledge/output/abatement_agreement_model4interactions.gph, 
title("", size(medlarge) margin(medsmall) color(black) position(6))
subtitle("Marginal Effect of Abatement Cost on Wales Pledge agreement", size(med) position(9) orientation(vertical) margin(medsmall) color(black));
graph save wales_pledge/output/abatement_agreement_allmodelsinteractions, replace;
graph export wales_pledge/output/abatement_agreement_allmodelsinteractions.tif, replace;


*****************************************************************************************************************
* Supplementary Version of MAIN TABLE (Table 4): Equipment Abatement Cost - All Interactions, adding land border*
*****************************************************************************************************************

*Generate russia_landborder_spatial*
#delimit;
gen russia_landborder_spatial=russia_spatial * russia_land_borderkm;

*Mean Comparison - try to find a way to order this by category instead of alphabetical*
#delimit;
tabstat abatement_equipment russia_landborder_spatial, by(qualcategory_walespledge);

*Model 1 (Baseline): Pledge = f(abatement_equipment cost, russia_landborder_spatial)*
#delimit;
reg qualscore_walespledge c.l.abatement_equipment##c.l.russia_landborder_spatial if year==2014 & nato_year_dummy==1;
outreg2 using "wales_pledge/output/walespledge_equipment_kmlandborder.xls", ctitle (Baseline - Abatement&Threat) label addtext() bdec(2) cdec(2) pdec(2) tdec(2) replace;
interflex qualscore_walespledge abatement_equipment capdist_russia if year==2014 & nato_year_dummy==1, type(linear) ylabel ("Wales Pledge Agreement") dlabel ("Abatement Cost") xlabel ("Russia Threat") sav(wales_pledge/output/abatement_equipment_model1);
graph save wales_pledge/output/abatement_agreement_model1interactions_supp, replace;


*Model 2 (Size: GDP)*
#delimit;
reg qualscore_walespledge c.l.abatement_equipment##c.l.russia_landborder_spatial c.l.rank_on_gdp##c.l.russia_landborder_spatial if year==2014 & nato_year_dummy==1;
outreg2 using "wales_pledge/output/walespledge_equipment_kmlandborder.xls", ctitle (Public Choice) label addtext() bdec(2) cdec(2) pdec(2) tdec(2) append;
interflex qualscore_walespledge abatement_equipment capdist_russia rank_on_gdp if year==2014 & nato_year_dummy==1, type(linear) ylabel ("Wales Pledge Agreement") dlabel ("Abatement Cost") xlabel ("Capital Distance from Moscow") sav(wales_pledge/output/abatement_equipment_model2);
graph save wales_pledge/output/abatement_agreement_model2interactions_supp, replace;

*Model 3 (Domestic Political Economy: right executive and uem)*
#delimit;
reg qualscore_walespledge c.l.abatement_equipment##c.l.russia_landborder_spatial c.l.rank_on_gdp##c.l.russia_landborder_spatial c.l.right##c.l.russia_landborder_spatial c.l.sl_uem_totl_zs##c.l.russia_landborder_spatial if year==2014 & nato_year_dummy==1;
outreg2 using "wales_pledge/output/walespledge_equipment_kmlandborder.xls", ctitle (Domestic PE) label addtext() bdec(2) cdec(2) pdec(2) tdec(2) append;
interflex qualscore_walespledge abatement_equipment capdist_russia rank_on_gdp right sl_uem_totl_zs if year==2014 & nato_year_dummy==1, type(linear) ylabel ("Wales Pledge Agreement") dlabel ("Abatement Cost") xlabel ("Capital Distance from Moscow") sav(wales_pledge/output/abatement_equipment_model3);
graph save wales_pledge/output/abatement_agreement_model3interactions_supp, replace;


*Model 4 (EU Political Economy: FRI)
#delimit;
reg qualscore_walespledge c.l.abatement_equipment##c.l.russia_landborder_spatial c.l.rank_on_gdp##c.l.russia_landborder_spatial c.l.right##c.l.russia_landborder_spatial c.l.sl_uem_totl_zs##c.l.russia_landborder_spatial c.l.fri##c.l.russia_landborder_spatial if year==2014 & nato_year_dummy==1;
outreg2 using "wales_pledge/output/walespledge_equipment_kmlandborder.xls", ctitle (EU PE) label addtext() bdec(2) cdec(2) pdec(2) tdec(2) append;
interflex qualscore_walespledge abatement_equipment capdist_russia rank_on_gdp right sl_uem_totl_zs fri if year==2014 & nato_year_dummy==1, type(linear) ylabel ("Pledge Agreement") dlabel ("Abatement") xlabel ("Capital Distance from Moscow");
graph save wales_pledge/output/abatement_agreement_model4interactions_supp, replace;
graph export wales_pledge/figures/figure4_abatement_agreement_model4interactions_supp.tif, replace;

grc1leg wales_pledge/output/abatement_agreement_model1interactions.gph wales_pledge/output/abatement_agreement_model2interactions.gph wales_pledge/output/abatement_agreement_model3interactions.gph
wales_pledge/output/abatement_agreement_model4interactions.gph, 
title("", size(medlarge) margin(medsmall) color(black) position(6))
subtitle("Marginal Effect of Abatement Cost on Wales Pledge agreement", size(med) position(9) orientation(vertical) margin(medsmall) color(black));
graph save wales_pledge/output/abatement_agreement_allmodelsinteractions_supp, replace;
graph export wales_pledge/output/abatement_agreement_allmodelsinteractions_supp.tif, replace;

************************************************************************************************************************
* Supplementary Version of MAIN TABLE (Table 4): Equipment Abatement Cost - All Interactions, using perception variable*
************************************************************************************************************************


*Mean Comparison - try to find a way to order this by category instead of alphabetical*
#delimit;
tabstat abatement_equipment russia_italy2015_poland2014, by(qualcategory_walespledge);

*Model 1 (Baseline): Pledge = f(abatement_equipment cost, russia_italy2015_poland2014)*
#delimit;
reg qualscore_walespledge c.l.abatement_equipment##c.l.russia_italy2015_poland2014 if year==2014 & nato_year_dummy==1;
outreg2 using "wales_pledge/output/walespledge_equipment_wordscores.xls", ctitle (Baseline - Abatement&Threat) label addtext() bdec(2) cdec(2) pdec(2) tdec(2) replace;
interflex qualscore_walespledge abatement_equipment capdist_russia if year==2014 & nato_year_dummy==1, type(linear) ylabel ("Wales Pledge Agreement") dlabel ("Abatement Cost") xlabel ("Russia Threat") sav(wales_pledge/output/abatement_equipment_model1);
graph save wales_pledge/output/abatement_agreement_model1interactions_suppsentiment, replace;


*Model 2 (Size: GDP)*
#delimit;
reg qualscore_walespledge c.l.abatement_equipment##c.l.russia_italy2015_poland2014 c.l.rank_on_gdp##c.l.russia_italy2015_poland2014 if year==2014 & nato_year_dummy==1;
outreg2 using "wales_pledge/output/walespledge_equipment_wordscores.xls", ctitle (Public Choice) label addtext() bdec(2) cdec(2) pdec(2) tdec(2) append;
interflex qualscore_walespledge abatement_equipment capdist_russia rank_on_gdp if year==2014 & nato_year_dummy==1, type(linear) ylabel ("Wales Pledge Agreement") dlabel ("Abatement Cost") xlabel ("Capital Distance from Moscow") sav(wales_pledge/output/abatement_equipment_model2);
graph save wales_pledge/output/abatement_agreement_model2interactions_suppsentiment, replace;

*Model 3 (Domestic Political Economy: right executive and uem)*
#delimit;
reg qualscore_walespledge c.l.abatement_equipment##c.l.russia_italy2015_poland2014 c.l.rank_on_gdp##c.l.russia_italy2015_poland2014 c.l.right##c.l.russia_italy2015_poland2014 c.l.sl_uem_totl_zs##c.l.russia_italy2015_poland2014 if year==2014 & nato_year_dummy==1;
outreg2 using "wales_pledge/output/walespledge_equipment_wordscores.xls", ctitle (Domestic PE) label addtext() bdec(2) cdec(2) pdec(2) tdec(2) append;
interflex qualscore_walespledge abatement_equipment capdist_russia rank_on_gdp right sl_uem_totl_zs if year==2014 & nato_year_dummy==1, type(linear) ylabel ("Wales Pledge Agreement") dlabel ("Abatement Cost") xlabel ("Capital Distance from Moscow") sav(wales_pledge/output/abatement_equipment_model3);
graph save wales_pledge/output/abatement_agreement_model3interactions_suppsentiment, replace;


*Model 4 (EU Political Economy: FRI)
#delimit;
reg qualscore_walespledge c.l.abatement_equipment##c.l.russia_italy2015_poland2014 c.l.rank_on_gdp##c.l.russia_italy2015_poland2014 c.l.right##c.l.russia_italy2015_poland2014 c.l.sl_uem_totl_zs##c.l.russia_italy2015_poland2014 c.l.fri##c.l.russia_italy2015_poland2014 if year==2014 & nato_year_dummy==1;
outreg2 using "wales_pledge/output/walespledge_equipment_wordscores.xls", ctitle (EU PE) label addtext() bdec(2) cdec(2) pdec(2) tdec(2) append;
interflex qualscore_walespledge abatement_equipment capdist_russia rank_on_gdp right sl_uem_totl_zs fri if year==2014 & nato_year_dummy==1, type(linear) ylabel ("Pledge Agreement") dlabel ("Abatement") xlabel ("Capital Distance from Moscow");
graph save wales_pledge/output/abatement_agreement_model4interactions_suppsentiment, replace;
graph export wales_pledge/figures/figure4_abatement_agreement_model4interactions_suppsentiment.tif, replace;

grc1leg wales_pledge/output/abatement_agreement_model1interactions.gph wales_pledge/output/abatement_agreement_model2interactions.gph wales_pledge/output/abatement_agreement_model3interactions.gph
wales_pledge/output/abatement_agreement_model4interactions.gph, 
title("", size(medlarge) margin(medsmall) color(black) position(6))
subtitle("Marginal Effect of Abatement Cost on Wales Pledge agreement", size(med) position(9) orientation(vertical) margin(medsmall) color(black));
graph save wales_pledge/output/abatement_agreement_allmodelsinteractions_suppsentiment, replace;
graph export wales_pledge/output/abatement_agreement_allmodelsinteractions_suppsentiment.tif, replace;


*****************************************
*TABLE 5: Wales Agreement and Compliance*
*****************************************
#delimit;
reg walesgrmilburden qualscore_walespledge if nato_year_dummy==1 & year==2020 & countryname !="Iceland" & countryname!="Montenegro" & countryname!="United States";
outreg2 using "wales_pledge/output/agreement_compliance.xls", ctitle (Milex/GDP) label addtext() bdec(2) cdec(2) pdec(2) tdec(2) replace;

reg walesgrequipment_gdp qualscore_walespledge if nato_year_dummy==1 & year==2020 & countryname !="Iceland" & countryname!="Montenegro" & countryname!="United States";
outreg2 using "wales_pledge/output/agreement_compliance.xls", ctitle (Equipment/GDP) label addtext() bdec(2) cdec(2) pdec(2) tdec(2) append;

**************************************************
* Equipment Abatement Cost and Compliance (Time) *
**************************************************
*Model 1 (Baseline): Compliance = f(abatement_equipment cost, russia_spatial)*
#delimit;
xtreg d.equipment_gdp c.l.abatement_equipment##c.l.russia_spatial year if year>=2015 & nato_year_dummy==1, fe robust cluster(ccode);
outreg2 using "wales_pledge/output/walescompliance_equipment.xls", ctitle (Baseline - Abatement&Threat) label addtext() bdec(2) cdec(2) pdec(2) tdec(2) replace;
interflex walesgrequipment_gdp abatement_equipment capdist_russia year if year>=2015 & nato_year_dummy==1, type(linear) ylabel ("Wales Pledge Agreement") dlabel ("Abatement Cost") xlabel ("Russia Threat") sav(wales_pledge/output/abatement_equipment_model1);
graph save wales_pledge/output/abatement_compliance_model1interactions, replace;


*Model 2 (Size: GDP)*
#delimit;
xtreg d.equipment_gdp c.l.abatement_equipment##c.l.russia_spatial c.l.rank_on_gdp##c.l.russia_spatial year if year>=2015 & nato_year_dummy==1, fe robust cluster(ccode);
outreg2 using "wales_pledge/output/walescompliance_equipment.xls", ctitle (Public Choice) label addtext() bdec(2) cdec(2) pdec(2) tdec(2) append;
interflex walesgrequipment_gdp abatement_equipment capdist_russia rank_on_gdp year if year>=2015 & nato_year_dummy==1, type(linear) ylabel ("Wales Pledge Agreement") dlabel ("Abatement Cost") xlabel ("Capital Distance from Moscow") sav(wales_pledge/output/abatement_equipment_model2);
graph save wales_pledge/output/abatement_compliance_model2interactions, replace;

*Model 3 (Domestic Political Economy: right executive and uem)*
#delimit;
xtreg d.equipment_gdp c.l.abatement_equipment##c.l.russia_spatial c.l.rank_on_gdp##c.l.russia_spatial c.l.right##c.l.russia_spatial c.l.sl_uem_totl_zs##c.l.russia_spatial year if year>=2015 & nato_year_dummy==1, fe robust cluster(ccode);
outreg2 using "wales_pledge/output/walescompliance_equipment.xls", ctitle (Domestic PE) label addtext() bdec(2) cdec(2) pdec(2) tdec(2) append;
interflex walesgrequipment_gdp abatement_equipment capdist_russia rank_on_gdp right sl_uem_totl_zs year if year>=2015 & nato_year_dummy==1, type(linear) ylabel ("Wales Pledge Agreement") dlabel ("Abatement Cost") xlabel ("Capital Distance from Moscow") sav(wales_pledge/output/abatement_equipment_model3);
graph save wales_pledge/output/abatement_compliance_model3interactions, replace;


*Model 4 (EU Political Economy: FRI)
#delimit;
xtreg d.equipment_gdp c.l.abatement_equipment##c.l.russia_spatial c.l.rank_on_gdp##c.l.russia_spatial c.l.right##c.l.russia_spatial c.l.sl_uem_totl_zs##c.l.russia_spatial c.l.fri##c.l.russia_spatial year if year>=2015 & nato_year_dummy==1, fe robust cluster(ccode);
outreg2 using "wales_pledge/output/walescompliance_equipment.xls", ctitle (EU PE) label addtext() bdec(2) cdec(2) pdec(2) tdec(2) append;
interflex walesgrequipment_gdp abatement_equipment capdist_russia rank_on_gdp right sl_uem_totl_zs fri year if year>=2015 & nato_year_dummy==1, type(linear) ylabel ("Pledge Compliance") dlabel ("Abatement") xlabel ("Capital Distance from Moscow");
graph save wales_pledge/output/abatement_compliance_model4interactions, replace;
graph export wales_pledge/figures/figure4_abatement_compliance_model4interactions.tif, replace;

grc1leg wales_pledge/output/abatement_compliance_model1interactions.gph wales_pledge/output/abatement_compliance_model2interactions.gph wales_pledge/output/abatement_compliance_model3interactions.gph
wales_pledge/output/abatement_compliance_model4interactions.gph, 
title("", size(medlarge) margin(medsmall) color(black) position(6))
subtitle("Marginal Effect of Abatement Cost on Wales Pledge Compliance", size(med) position(9) orientation(vertical) margin(medsmall) color(black));
graph save wales_pledge/output/abatement_compliance_allmodelsinteractions, replace;
graph export wales_pledge/output/abatement_compliance_allmodelsinteractions.tif, replace;





*********
*FIGURES*
*********

*Figure 1: Disaggregated Bars*
#delimit;
preserve;
keep if [year==2014|year==2023] & nato_year_dummy==1&countryname!="Iceland" & countryname !="Montenegro" & countryname!="Macedonia";
graph bar (mean) equipment_gdp (mean) personnel_gdp (mean) operating_gdp (mean) infrastructure_gdp, scheme (s2mono) 
over (year, label(labcolor(red) angle(ninety) labsize(tiny))) 
over(countryname, label(labcolor(black) 
angle(forty_five) labsize(vsmall))) stack yline(2 .4, lcolor(red) lpattern(dash) lwidth(medthick)) 
ytitle("Expenditures/GDP (%), by category (2014 & 2023)", size(small) margin(medium)) legend(rows(1) position(6)  size(vsmall) 
label (1 "equipment") label (2 "personnel") label (3 "O&M")  label (4 "infrastructure")) ysize (10) ylab(0(.5)4, labsize(vsmall));
graph save wales_pledge\output\Figure1disagg_all.gph, replace;
graph export wales_pledge\figures\Figure1disagg_all.tif, replace;
restore;



*Figure 2: Scatter Plot Abatement Cost, Threat and Wales Pledge Adoption*
*Figure 2A Abatement Cost*
#delimit;
preserve;
sort ccode year;
xtset ccode year;
keep if year==2014 & nato_dummy==1;
reg qualscore_walespledge abatement;
local r2: display %5.2f e(r2);
corr qualscore_walespledge abatement;
local r: display %5.2f r(rho);
collapse qualscore_walespledge abatement, by(isoalpha);
twoway (lfit qualscore_walespledge abatement) 
(scatter qualscore_walespledge abatement, msymbol(diamond) mcolor(navy) msize(medsmall) mlabsize(vsmall) mlabcolor(black) mlabel(isoalpha)),
xtitle("", size(medsmall) margin(medsmall))
ytitle("", size(medium) margin(medsmall))
legend(rows(1) size(tiny) position(7) ring(0) label(1 Fitted) label(2 Observed))
title("A: Abatement Cost", size(medlarge))
note(R=`r');
graph save wales_pledge/output/Abatement.gph, replace;
restore;

*Figure 2B Equipment-Adjusted Abatement Cost*
#delimit;
preserve;
sort ccode year;
xtset ccode year;
keep if year==2014 & nato_dummy==1;
reg qualscore_walespledge abatement_equipment;
local r2: display %5.2f e(r2);
corr qualscore_walespledge abatement_equipment;
local r: display %5.2f r(rho);
collapse qualscore_walespledge abatement_equipment, by(isoalpha);
twoway (lfit qualscore_walespledge abatement_equipment) 
(scatter qualscore_walespledge abatement_equipment, msymbol(diamond) mcolor(navy) msize(medsmall) mlabsize(vsmall) mlabcolor(black) mlabel(isoalpha)),
xtitle("", size(medsmall) margin(medsmall))
ytitle("", size(medium) margin(medsmall))
legend(rows(1) size(tiny) position(7) ring(0) label(1 Fitted) label(2 Observed))
title("B: Equipment Adjusted Abatement Cost", size(medlarge))
note(R=`r');
graph save wales_pledge/output/abatement_equipment.gph, replace;
restore;

*Figure 2C Threat Vulnerability*
#delimit;
preserve;
sort ccode year;
xtset ccode year;
keep if year==2014 & nato_dummy==1;
reg qualscore_walespledge russia_spatial;
local r2: display %5.2f e(r2);
corr qualscore_walespledge russia_spatial;
local r: display %5.2f r(rho);
collapse qualscore_walespledge russia_spatial, by(isoalpha);
twoway (lfit qualscore_walespledge russia_spatial) 
(scatter qualscore_walespledge russia_spatial, msymbol(diamond) mcolor(navy) msize(medsmall) mlabsize(vsmall) mlabcolor(black) mlabel(isoalpha)),
xtitle("", size(medsmall) margin(medsmall))
ytitle("", size(medium) margin(medsmall))
legend(rows(1) size(tiny) position(5) ring(0) label(1 Fitted) label(2 Observed))
title("C: Threat Proximity", size(medlarge))
note(R=`r');
graph save wales_pledge/output/russia_spatial.gph, replace;
restore;

*Figure 2D Threat Perception*
#delimit;
preserve;
sort ccode year;
xtset ccode year;
keep if year==2014 & nato_dummy==1;
reg qualscore_walespledge wsthreat_spain_poland;
local r2: display %5.2f e(r2);
corr qualscore_walespledge wsthreat_spain_poland;
local r: display %5.2f r(rho);
collapse qualscore_walespledge wsthreat_spain_poland, by(isoalpha);
twoway (lfit qualscore_walespledge wsthreat_spain_poland) 
(scatter qualscore_walespledge wsthreat_spain_poland, msymbol(diamond) mcolor(navy) msize(medsmall) mlabsize(vsmall) mlabcolor(black) mlabel(isoalpha)),
xtitle("", size(medsmall) margin(medsmall))
ytitle("", size(medium) margin(medsmall))
legend(rows(1) size(tiny) position(5) ring(0) label(1 Fitted) label(2 Observed))
title("D: Threat Perception", size(medlarge))
note(R=`r');
graph save wales_pledge/output/wsthreat_spain_poland.gph, replace;
restore;

*Figure 2E Terrorism & Political Violence Vulnerability*
#delimit;
preserve;
sort ccode year;
xtset ccode year;
keep if year==2014 & nato_dummy==1;
reg qualscore_walespledge pv_est;
local r2: display %5.2f e(r2);
corr qualscore_walespledge pv_est;
local r: display %5.2f r(rho);
collapse qualscore_walespledge pv_est, by(isoalpha);
twoway (lfit qualscore_walespledge pv_est) 
(scatter qualscore_walespledge pv_est, msymbol(diamond) mcolor(navy) msize(medsmall) mlabsize(vsmall) mlabcolor(black) mlabel(isoalpha)),
xtitle("", size(medsmall) margin(medsmall))
ytitle("", size(medium) margin(medsmall))
legend(rows(1) size(tiny) position(5) ring(0) label(1 Fitted) label(2 Observed))
title("D: Political Violence Vulnerability", size(medlarge))
note(R=`r');
graph save wales_pledge/output/pv_est.gph, replace;
restore;

#delimit;
grc1leg wales_pledge/output/Abatement.gph  wales_pledge/output/abatement_equipment.gph  wales_pledge/output/russia_spatial.gph wales_pledge/output/pv_est.gph, 
title("Abatement Cost/Threat Vulnerability", size(medlarge) margin(medsmall) color(black) position(6))
subtitle("Wales Pledge Enthusiasm/Agreement", size(medarge) position(9) orientation(vertical) margin(medsmall) color(black));
graph save wales_pledge/output/figure2_scatter, replace;
graph export wales_pledge/figures/figure2_scatter.tif, replace;



*Possible Robustness Tables*


************************
* Basic Abatement Cost *
************************

*Mean Comparison - try to find a way to order this by category instead of alphabetical*
tabstat abatement russia_spatial, by(qualcategory_walespledge)

*Model 1 (Baseline): Pledge = f(abatement cost, russia_spatial)*
reg qualscore_walespledge c.l.abatement##c.l.russia_spatial 
outreg2 using "wales_pledge/output/walespledge_basic.xls", ctitle (Baseline - Abatement&Threat) label addtext() bdec(2) cdec(2) pdec(2) tdec(2) replace

*Model 2 (Size: GDP)*
reg qualscore_walespledge l.abatement l.russia_spatial l.rank_on_gdp
outreg2 using "wales_pledge/output/walespledge_basic.xls", ctitle (Public Choice) label addtext() bdec(2) cdec(2) pdec(2) tdec(2) append

*Model 3 (Domestic Political Economy: right executive and uem)*
reg qualscore_walespledge l.abatement l.russia_spatial l.rank_on_gdp l.right l.sl_uem_totl_zs
outreg2 using "wales_pledge/output/walespledge_basic.xls", ctitle (Domestic PE) label addtext() bdec(2) cdec(2) pdec(2) tdec(2) append

*Model 4 (EU Political Economy: FRI)
reg qualscore_walespledge l.abatement l.russia_spatial l.rank_on_gdp l.right l.sl_uem_totl_zs l.fri
outreg2 using "wales_pledge/output/walespledge_basic.xls", ctitle (EU PE) label addtext() bdec(2) cdec(2) pdec(2) tdec(2) append

****************************
* Equipment Abatement Cost *
****************************

*Mean Comparison - try to find a way to order this by category instead of alphabetical*
#delimit;
tabstat abatement_equipment russia_spatial, by(qualcategory_walespledge);

*Model 1 (Baseline): Pledge = f(abatement_equipment cost, russia_spatial)*
#delimit;
reg qualscore_walespledge c.l.abatement_equipment##c.l.russia_spatial if year==2014 & nato_year_dummy==1;
outreg2 using "wales_pledge/output/walespledge_equipment.xls", ctitle (Baseline - Abatement&Threat) label addtext() bdec(2) cdec(2) pdec(2) tdec(2) replace;
interflex qualscore_walespledge abatement_equipment capdist_russia if year==2014 & nato_year_dummy==1, type(linear) ylabel ("Wales Pledge Agreement") dlabel ("Abatement Cost") xlabel ("Russia Threat") sav(wales_pledge/output/abatement_equipment_model1);
graph save wales_pledge/output/abatement_agreement_model1, replace;


*Model 2 (Size: GDP)*
#delimit;
reg qualscore_walespledge l.abatement_equipment l.russia_spatial l.rank_on_gdp if year==2014 & nato_year_dummy==1;
outreg2 using "wales_pledge/output/walespledge_equipment.xls", ctitle (Public Choice) label addtext() bdec(2) cdec(2) pdec(2) tdec(2) append;
interflex qualscore_walespledge abatement_equipment capdist_russia rank_on_gdp if year==2014 & nato_year_dummy==1, type(linear) ylabel ("Wales Pledge Agreement") dlabel ("Abatement Cost") xlabel ("Russia Threat") sav(wales_pledge/output/abatement_equipment_model2);
graph save wales_pledge/output/abatement_agreement_model2, replace;

*Model 3 (Domestic Political Economy: right executive and uem)*
#delimit;
reg qualscore_walespledge l.abatement_equipment l.russia_spatial l.rank_on_gdp l.right l.sl_uem_totl_zs if year==2014 & nato_year_dummy==1;
outreg2 using "wales_pledge/output/walespledge_equipment.xls", ctitle (Domestic PE) label addtext() bdec(2) cdec(2) pdec(2) tdec(2) append;
interflex qualscore_walespledge abatement_equipment capdist_russia rank_on_gdp right sl_uem_totl_zs if year==2014 & nato_year_dummy==1, type(linear) ylabel ("Wales Pledge Agreement") dlabel ("Abatement Cost") xlabel ("Russia Threat") sav(wales_pledge/output/abatement_equipment_model3);
graph save wales_pledge/output/abatement_agreement_model3, replace;


*Model 4 (EU Political Economy: FRI)
#delimit;
reg qualscore_walespledge l.abatement_equipment l.russia_spatial l.rank_on_gdp l.right l.sl_uem_totl_zs l.fri if year==2014 & nato_year_dummy==1;
outreg2 using "wales_pledge/output/walespledge_equipment.xls", ctitle (EU PE) label addtext() bdec(2) cdec(2) pdec(2) tdec(2) append;
interflex qualscore_walespledge abatement_equipment capdist_russia rank_on_gdp right sl_uem_totl_zs fri if year==2014 & nato_year_dummy==1, type(linear) ylabel ("Wales Pledge Agreement") dlabel ("Abatement Cost") xlabel ("Russia Threat") sav(wales_pledge/output/abatement_equipment_model4);
graph save wales_pledge/output/abatement_agreement_model4, replace;

grc1leg wales_pledge/output/abatement_agreement_model1.gph wales_pledge/output/abatement_agreement_model2.gph wales_pledge/output/abatement_agreement_model3.gph
wales_pledge/output/abatement_agreement_model4.gph, 
title("", size(medlarge) margin(medsmall) color(black) position(6))
subtitle("Marginal Effect of Abatement Cost on Wales Pledge agreement", size(med) position(9) orientation(vertical) margin(medsmall) color(black));
graph save wales_pledge/output/abatement_agreement_allmodels, replace;
graph export wales_pledge/output/abatement_agreement_allmodels.tif, replace;










************************************************
* Equipment Abatement Cost - Threat Perception *
************************************************

*Mean Comparison - try to find a way to order this by category instead of alphabetical*
#delimit;
tabstat abatement_equipment wsthreat_spain_poland, by(qualcategory_walespledge);

*Model 1 (Baseline): Pledge = f(abatement_equipment cost, wsthreat_spain_poland)*
#delimit;
reg qualscore_walespledge c.l.abatement_equipment##c.l.wsthreat_spain_poland if year==2014 & nato_year_dummy==1;
outreg2 using "wales_pledge/output/walespledge_equipment.xls", ctitle (Baseline - Abatement&Threat) label addtext() bdec(2) cdec(2) pdec(2) tdec(2) replace;
interflex qualscore_walespledge abatement_equipment wsthreat_spain_poland if year==2014 & nato_year_dummy==1, type(linear) ylabel ("Wales Pledge Agreement") dlabel ("Abatement Cost") xlabel ("Russia Threat") sav(wales_pledge/output/abatement_equipment_model1);
graph save wales_pledge/output/abatement_agreement_model1, replace;


*Model 2 (Size: GDP)*
#delimit;
reg qualscore_walespledge l.abatement_equipment l.wsthreat_spain_poland l.rank_on_gdp if year==2014 & nato_year_dummy==1;
outreg2 using "wales_pledge/output/walespledge_equipment.xls", ctitle (Public Choice) label addtext() bdec(2) cdec(2) pdec(2) tdec(2) append;
interflex qualscore_walespledge abatement_equipment wsthreat_spain_poland rank_on_gdp if year==2014 & nato_year_dummy==1, type(linear) ylabel ("Wales Pledge Agreement") dlabel ("Abatement Cost") xlabel ("Russia Threat") sav(wales_pledge/output/abatement_equipment_model2);
graph save wales_pledge/output/abatement_agreement_model2, replace;

*Model 3 (Domestic Political Economy: right executive and uem)*
#delimit;
reg qualscore_walespledge l.abatement_equipment l.wsthreat_spain_poland l.rank_on_gdp l.right l.sl_uem_totl_zs if year==2014 & nato_year_dummy==1;
outreg2 using "wales_pledge/output/walespledge_equipment.xls", ctitle (Domestic PE) label addtext() bdec(2) cdec(2) pdec(2) tdec(2) append;
interflex qualscore_walespledge abatement_equipment wsthreat_spain_poland rank_on_gdp right sl_uem_totl_zs if year==2014 & nato_year_dummy==1, type(linear) ylabel ("Wales Pledge Agreement") dlabel ("Abatement Cost") xlabel ("Russia Threat") sav(wales_pledge/output/abatement_equipment_model3);
graph save wales_pledge/output/abatement_agreement_model3, replace;


*Model 4 (EU Political Economy: FRI)
#delimit;
reg qualscore_walespledge l.abatement_equipment l.wsthreat_spain_poland l.rank_on_gdp l.right l.sl_uem_totl_zs l.fri if year==2014 & nato_year_dummy==1;
outreg2 using "wales_pledge/output/walespledge_equipment.xls", ctitle (EU PE) label addtext() bdec(2) cdec(2) pdec(2) tdec(2) append;
interflex qualscore_walespledge abatement_equipment wsthreat_spain_poland rank_on_gdp right sl_uem_totl_zs fri if year==2014 & nato_year_dummy==1, type(linear) ylabel ("Wales Pledge Agreement") dlabel ("Abatement Cost") xlabel ("Russia Threat") sav(wales_pledge/output/abatement_equipment_model4);
graph save wales_pledge/output/abatement_agreement_model4, replace;

grc1leg wales_pledge/output/abatement_agreement_model1.gph wales_pledge/output/abatement_agreement_model2.gph wales_pledge/output/abatement_agreement_model3.gph
wales_pledge/output/abatement_agreement_model4.gph, 
title("", size(medlarge) margin(medsmall) color(black) position(6))
subtitle("Marginal Effect of Abatement Cost on Wales Pledge agreement", size(med) position(9) orientation(vertical) margin(medsmall) color(black));
graph save wales_pledge/output/abatement_agreement_allmodels, replace;
graph export wales_pledge/figures/abatement_agreement_allmodels.tif, replace;


*******************************************************
* Equipment Abatement Cost (Political Violence Threat)*
*******************************************************

*Mean Comparison - try to find a way to order this by category instead of alphabetical*
#delimit;
tabstat abatement_equipment pv_est, by(qualcategory_walespledge);

*Model 1 (Baseline): Pledge = f(abatement_equipment cost, pv_est)*
#delimit;
reg qualscore_walespledge c.l.abatement_equipment##c.l.pv_est;
outreg2 using "wales_pledge/output/walespledge_equipment_pv.xls", ctitle (Baseline - abatement_equipment&Threat) label addtext() bdec(2) cdec(2) pdec(2) tdec(2) replace;

*Model 2 (Size: GDP)*
#delimit;
reg qualscore_walespledge l.abatement_equipment l.pv_est l.rank_on_gdp;
outreg2 using "wales_pledge/output/walespledge_equipment_pv.xls", ctitle (Public Choice) label addtext() bdec(2) cdec(2) pdec(2) tdec(2) append;

*Model 3 (Domestic Political Economy: right executive and uem)*
#delimit;
reg qualscore_walespledge l.abatement_equipment l.pv_est l.rank_on_gdp l.right l.sl_uem_totl_zs;
outreg2 using "wales_pledge/output/walespledge_equipment_pv.xls", ctitle (Domestic PE) label addtext() bdec(2) cdec(2) pdec(2) tdec(2) append;

*Model 4 (EU Political Economy: FRI)
#delimit;
reg qualscore_walespledge l.abatement_equipment l.pv_est l.rank_on_gdp l.right l.sl_uem_totl_zs l.fri;
outreg2 using "wales_pledge/output/walespledge_equipment_pv.xls", ctitle (EU PE) label addtext() bdec(2) cdec(2) pdec(2) tdec(2) append;


*************************************
* Simple Abatement Opportunity Cost *
*************************************
#delimit;
preserve;
rangestat (reg) ggdp log_investmentgdp ln_equipment_gdp gln_pop lag_ln_gdp, by(ccode) interval(ggdp . .) ;

*Mean Comparison - try to find a way to order this by category instead of alphabetical*
#delimit;
tabstat b_ln_equipment_gdp russia_spatial, by(qualcategory_walespledge);

*Model 1 (Baseline): Pledge = f(b_ln_equipment_gdp cost, russia_spatial)*
#delimit;
reg qualscore_walespledge c.l.b_ln_equipment_gdp##c.l.russia_spatial if year ==2014 & nato_dummy==1;
outreg2 using "wales_pledge/output/walespledge_opportunitycost.xls", ctitle (Baseline - Abatement&Threat) label addtext() bdec(2) cdec(2) pdec(2) tdec(2) replace;

*Model 2 (Size: GDP) Excluded Because Embedded in Abatement Calculation*
*reg qualscore_walespledge_opportunitycost l.b_ln_equipment_gdp l.russia_spatial l.rank_on_gdp
*outreg2 using "wales_pledge/output/walespledge_opportunitycost.xls", ctitle (Public Choice) label addtext() bdec(2) cdec(2) pdec(2) tdec(2) append

*Model 2 (Domestic Political Economy: right executive and uem)*
#delimit;
reg qualscore_walespledge c.l.b_ln_equipment_gdp##c.l.russia_spatial l.right l.sl_uem_totl_zs if year ==2014 & nato_dummy==1;
outreg2 using "wales_pledge/output/walespledge_opportunitycost.xls", ctitle (Domestic PE) label addtext() bdec(2) cdec(2) pdec(2) tdec(2) append;

*Model 3 (EU Political Economy: FRI)
#delimit;
reg qualscore_walespledge c.l.b_ln_equipment_gdp##c.l.russia_spatial  l.right l.sl_uem_totl_zs l.fri if year ==2014 & nato_dummy==1;
outreg2 using "wales_pledge/output/walespledge_opportunitycost.xls", ctitle (EU PE) label addtext() bdec(2) cdec(2) pdec(2) tdec(2) append;

restore;

*******************************
* Abatement Opportunity Cost *
*******************************

*Mean Comparison - try to find a way to order this by category instead of alphabetical*
tabstat abatement_opportunity russia_spatial, by(qualcategory_walespledge)

*Model 1 (Baseline): Pledge = f(abatement_opportunity cost, russia_spatial)*
reg qualscore_walespledge c.l.abatement_opportunity##c.l.russia_spatial 
outreg2 using "wales_pledge/output/walespledge_opportunitycost.xls", ctitle (Baseline - Abatement&Threat) label addtext() bdec(2) cdec(2) pdec(2) tdec(2) replace

*Model 2 (Size: GDP) Excluded Because Embedded in Abatement Calculation*
*reg qualscore_walespledge_opportunitycost l.abatement_opportunity l.russia_spatial l.rank_on_gdp
*outreg2 using "wales_pledge/output/walespledge_opportunitycost.xls", ctitle (Public Choice) label addtext() bdec(2) cdec(2) pdec(2) tdec(2) append

*Model 2 (Domestic Political Economy: right executive and uem)*
reg qualscore_walespledge c.l.abatement_opportunity##c.l.russia_spatial l.right l.sl_uem_totl_zs
outreg2 using "wales_pledge/output/walespledge_opportunitycost.xls", ctitle (Domestic PE) label addtext() bdec(2) cdec(2) pdec(2) tdec(2) append

*Model 3 (EU Political Economy: FRI)
reg qualscore_walespledge c.l.abatement_opportunity##c.l.russia_spatial  l.right l.sl_uem_totl_zs l.fri
outreg2 using "wales_pledge/output/walespledge_opportunitycost.xls", ctitle (EU PE) label addtext() bdec(2) cdec(2) pdec(2) tdec(2) append


**************************************
* Rank on Abatement Opportunity Cost *
**************************************

*Mean Comparison - try to find a way to order this by category instead of alphabetical*
tabstat rank_abatement_opportunity russia_spatial, by(qualcategory_walespledge)

*Model 1 (Baseline): Pledge = f(rank_abatement_opportunity cost, russia_spatial)*
reg qualscore_walespledge c.l.rank_abatement_opportunity##c.l.russia_spatial 
outreg2 using "wales_pledge/output/walespledge_opportunitycost_rank.xls", ctitle (Baseline - Abatement&Threat) label addtext() bdec(2) cdec(2) pdec(2) tdec(2) replace

*Model 2 (Size: GDP) Excluded Because Embedded in Abatement Calculation*
*reg qualscore_walespledge_opportunitycost_rank l.rank_abatement_opportunity l.russia_spatial l.rank_on_gdp
*outreg2 using "wales_pledge/output/walespledge_opportunitycost_rank.xls", ctitle (Public Choice) label addtext() bdec(2) cdec(2) pdec(2) tdec(2) append

*Model 2 (Domestic Political Economy: right executive and uem)*
reg qualscore_walespledge c.l.rank_abatement_opportunity##c.l.russia_spatial l.right l.sl_uem_totl_zs
outreg2 using "wales_pledge/output/walespledge_opportunitycost_rank.xls", ctitle (Domestic PE) label addtext() bdec(2) cdec(2) pdec(2) tdec(2) append

*Model 3 (EU Political Economy: FRI)
reg qualscore_walespledge c.l.rank_abatement_opportunity##c.l.russia_spatial  l.right l.sl_uem_totl_zs l.fri
outreg2 using "wales_pledge/output/walespledge_opportunitycost_rank.xls", ctitle (EU PE) label addtext() bdec(2) cdec(2) pdec(2) tdec(2) append

restore

**************************************************
* Equipment Abatement Cost and Compliance (2020) *
**************************************************

*Mean Comparison - try to find a way to order this by category instead of alphabetical*
#delimit;
tabstat abatement_equipment capdist_russia if year==2020 & nato_year_dummy==1, by(walesgrequipment_gdp);

*Model 1 (Baseline): Pledge = f(abatement_equipment cost, capdist_russia)*
#delimit;
reg walesgrequipment_gdp c.l.abatement_equipment##c.l.capdist_russia if year==2020 & nato_year_dummy==1;
outreg2 using "wales_pledge/output/walescompliance_equipment.xls", ctitle (Baseline - abatement_equipment&Threat) label addtext() bdec(2) cdec(2) pdec(2) tdec(2) replace;
interflex walesgrequipment_gdp abatement_equipment capdist_russia rank_on_gdp right sl_uem_totl_zs if year==2020 & nato_year_dummy==1, type(linear) ylabel ("") dlabel ("") xlabel ("Russia Threat") sav(wales_pledge/output/abatement_compliance_model1.tif);
graph save wales_pledge/output/abatement_compliance_model1.gph, replace;


*Model 2 (Size: GDP)*
#delimit;
reg walesgrequipment_gdp l.abatement_equipment l.capdist_russia l.rank_on_gdp if year==2020 & nato_year_dummy==1;
outreg2 using "wales_pledge/output/walescompliance_equipment.xls", ctitle (Public Choice) label addtext() bdec(2) cdec(2) pdec(2) tdec(2) append;
interflex walesgrequipment_gdp abatement_equipment capdist_russia rank_on_gdp if year==2020 & nato_year_dummy==1, type(linear) ylabel ("") dlabel ("") xlabel ("Russia Threat") sav(wales_pledge/output/abatement_compliance_model2.tif);
graph save wales_pledge/output/abatement_compliance_model2.gph, replace;


*Model 3 (Domestic Political Economy: right executive and uem)*
#delimit;
reg walesgrequipment_gdp l.abatement_equipment l.capdist_russia l.rank_on_gdp l.right l.sl_uem_totl_zs if year==2020 & nato_year_dummy==1;
outreg2 using "wales_pledge/output/walescompliance_equipment.xls", ctitle (Domestic PE) label addtext() bdec(2) cdec(2) pdec(2) tdec(2) append;
interflex walesgrequipment_gdp abatement_equipment capdist_russia rank_on_gdp right sl_uem_totl_zs if year==2020 & nato_year_dummy==1, type(linear) ylabel ("") dlabel ("") xlabel ("Russia Threat") sav(wales_pledge/output/abatement_compliance_model3.tif);
graph save wales_pledge/output/abatement_compliance_model3.gph, replace;


*Model 4 (EU Political Economy: FRI)
#delimit;
gen fri_2018=l2.fri if year==2020;
reg walesgrequipment_gdp l.abatement_equipment l.capdist_russia l.rank_on_gdp l.right l.sl_uem_totl_zs l2.fri if year==2020 & nato_year_dummy==1;
outreg2 using "wales_pledge/output/walescompliance_equipment.xls", ctitle (EU PE) label addtext() bdec(2) cdec(2) pdec(2) tdec(2) append;
interflex walesgrequipment_gdp abatement_equipment capdist_russia rank_on_gdp right sl_uem_totl_zs fri_2018 if year==2020 & nato_year_dummy==1, type(linear) ylabel ("") dlabel ("") xlabel ("Russia Threat") sav(wales_pledge/output/abatement_compliance_model4.tif);
graph save wales_pledge/output/abatement_compliance_model4.gph, replace;

grc1leg wales_pledge/output/abatement_compliance_model1.gph wales_pledge/output/abatement_compliance_model2.gph wales_pledge/output/abatement_compliance_model3.gph
wales_pledge/output/abatement_compliance_model4.gph, 
title("", size(medlarge) margin(medsmall) color(black) position(6))
subtitle("Marginal Effect of Abatement Cost on Wales Pledge Compliance", size(med) position(9) orientation(vertical) margin(medsmall) color(black));
graph save wales_pledge/output/abatement_compliance_allmodels, replace;
graph export wales_pledge/output/abatement_compliance_allmodels.tif, replace;
